package com.fishingwithme.infrastructure.dtos;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;

public class DtoConverter {
        public static <T, R> List<R> convertList(List<T> source, Function<T, R> converter) {
            return Optional.ofNullable(source)
                    .orElse(Collections.emptyList())
                    .stream()
                    .map(converter)
                    .collect(Collectors.toList());
        }
}
